﻿using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Holoville.HOTween;

public partial class BattlefieldFriendScene : Scene
{
	List<FriendModel> ExtractDefaultFriendList(List<FriendModel> friendList)
	{
		List<FriendModel> _fl = new List<FriendModel>();
		foreach(FriendModel _fm in friendList)
		{
			if (_fm.type == 1)
				_fl.Add(_fm);
		}
		
		return _fl;
	}

	public FriendModel[] Shuffle(FriendModel[] source)
	{
		for (int i = 0; i < source.Length; i++)
		{
			int idx =  UnityEngine.Random.Range(0, source.Length - 1);
			FriendModel temp = source[i];
			source[i] = source[idx];
			source[idx] = temp;
		}
		return source;
	}

	public string DatetimeToFomattedString(long dateGap)
	{
		DateTime nowDate = DateTime.Now;
		
		DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
		DateTime targetDate = startDate.AddMilliseconds(dateGap).ToLocalTime();
		
		TimeSpan ts = nowDate - targetDate;
		
		if (ts.Days >= 60)
		{
			return Localization.Get("uiFriendTimeTypeD");
		}
		else if (ts.Days >= 1)
		{
			return string.Format(Localization.Get("uiFriendTimeTypeA"), ts.Days.ToString());
			//return string.Format("[AAAAFF]" + Localization.Get("uiFriendTimeTypeA"), ts.Days.ToString());
		}
		else if (ts.Hours > 0)
		{
			return string.Format(Localization.Get("uiFriendTimeTypeB"), ts.Hours.ToString(), ts.Minutes.ToString());
			//return string.Format("[AAAAFF]" + Localization.Get("uiFriendTimeTypeB"), ts.Hours.ToString(), ts.Minutes.ToString());
		}
		else
		{
			return string.Format(Localization.Get("uiFriendTimeTypeC"), ts.Minutes.ToString());
			//return string.Format("[AAAAFF]" + Localization.Get("uiFriendTimeTypeC"), ts.Minutes.ToString());
		}
	}
}